Add a condition that restricts the data returned in a query.
Parent Type: LearningStoreQuery
Namespace: Microsoft.LearningComponents.Storage
Assembly: Microsoft.LearningComponents.Storage.dll
| C# |
|
public void AddCondition ( ) |
columnName
Name of the column to be compared
conditionOperator
Condition operator
conditionValue
Value to be compared against.
| Exception type | Condition |
| ArgumentNullException | columnName is a null reference. |
| ArgumentOutOfRangeException | conditionOperator is invalid. |
| InvalidOperationException | Invalid comparison, the column name wasn't found in the view, or an invalid conditionValue value. |
See the LearningStoreQuery documentation for more information about creating and executing queries.
conditionValue must contain a value that is valid based on the type of the column specified by columnName:
conditionValue must not contain a LearningStoreItemIdentifier returned from LearningStoreJob.AddItem.
If columnName refers to an XML column, then the following restrictions apply:
If columnName refers to an Guid column, then the following restrictions apply:
If conditionOperator is LearningStoreConditionOperator.GreaterThan, LearningStoreConditionOperator.GreaterThanEqual, LearningStoreConditionOperator.LessThan, or LearningStoreConditionOperator.LessThanEqual, then conditionValue must not contain null.
Care must be taken when null is involved in a comparison. In particular:
The following code creates a new query that returns the id and name of the users with a name less than "Joe":
| C# |
LearningStoreQuery query = store.CreateQuery("UserItem");
query.AddColumn("Id");
query.AddColumn("Name");
query.AddCondition("Name", LearningStoreConditionOperator.LessThan, "Joe");
|